package com.ruoyi.edgebox.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.edgebox.domain.AimpEdgeBox;
import com.ruoyi.edgebox.service.IAimpEdgeBoxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 边缘盒子Controller
 * 
 * @author ruoyi
 * @date 2022-06-02
 */
@RestController
@RequestMapping("/equipment/edgebox")
public class AimpEdgeBoxController extends BaseController
{
    @Autowired
    private IAimpEdgeBoxService aimpEdgeBoxService;

    /**
     * 查询边缘盒子列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:edgebox:list')")
    @GetMapping("/list")
    public TableDataInfo list(AimpEdgeBox aimpEdgeBox)
    {
        startPage();
        List<AimpEdgeBox> list = aimpEdgeBoxService.selectAimpEdgeBoxList(aimpEdgeBox);
        return getDataTable(list);
    }

    /**
     * 导出边缘盒子列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:edgebox:export')")
    @Log(title = "边缘盒子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AimpEdgeBox aimpEdgeBox)
    {
        List<AimpEdgeBox> list = aimpEdgeBoxService.selectAimpEdgeBoxList(aimpEdgeBox);
        ExcelUtil<AimpEdgeBox> util = new ExcelUtil<AimpEdgeBox>(AimpEdgeBox.class);
        util.exportExcel(response, list, "边缘盒子数据");
    }

    /**
     * 获取边缘盒子详细信息
     */
    @PreAuthorize("@ss.hasPermi('equipment:edgebox:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(aimpEdgeBoxService.selectAimpEdgeBoxById(id));
    }

    /**
     * 新增边缘盒子
     */
    @PreAuthorize("@ss.hasPermi('equipment:edgebox:add')")
    @Log(title = "边缘盒子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AimpEdgeBox aimpEdgeBox)
    {
        return toAjax(aimpEdgeBoxService.insertAimpEdgeBox(aimpEdgeBox));
    }

    /**
     * 修改边缘盒子
     */
    @PreAuthorize("@ss.hasPermi('equipment:edgebox:edit')")
    @Log(title = "边缘盒子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AimpEdgeBox aimpEdgeBox)
    {
        return toAjax(aimpEdgeBoxService.updateAimpEdgeBox(aimpEdgeBox));
    }

    /**
     * 删除边缘盒子
     */
    @PreAuthorize("@ss.hasPermi('equipment:edgebox:remove')")
    @Log(title = "边缘盒子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(aimpEdgeBoxService.deleteAimpEdgeBoxByIds(ids));
    }
}
